import { IMOptionsType } from "@/types/dict";
import { IMTableType } from "@/types/table";
import { DrawerFormStateType } from "./type";
export let columns = reactive<IMTableType[]>([
  { title: getProxyT("base.index"), dataIndex: "index", key: "index" },
  {
    title: computed(() => `${$t("table179")}ID`),
    dataIndex: "pay_merchant_no",
    key: "pay_merchant_no",
  },
  { title: getProxyT("table180"), dataIndex: "name", key: "name" },
  {
    title: getProxyT("table181"),
    dataIndex: "payCapacity",
    key: "payCapacity",
  },
  {
    title: getProxyT("table182"),
    dataIndex: "support_pay_passageways",
    key: "support_pay_passageways",
  },
  {
    title: getProxyT("table31"),
    dataIndex: "is_disabled",
    key: "is_disabled",
  },
  { title: getProxyT("table78"), dataIndex: "comment", key: "comment" },
  {
    title: getProxyT("table43"),
    dataIndex: "create_time",
    key: "create_time",
    customRender: ({ text }: any) => getTimeByZone(text),
  },
  {
    title: getProxyT("table44"),
    dataIndex: "update_time",
    key: "update_time",
    customRender: ({ text }: any) => getTimeByZone(text),
  },
  {
    title: getProxyT("table23"),
    dataIndex: "analysis_name",
    key: "analysis_name",
  },
  { title: getProxyT("base.action"), key: "action" },
]);
export const queryParams = reactive<any>({});
export const searchPayCapacityOptions = ref<any>([]);
export const searchPayTypeOptions = ref<any>([]);
export const searchPayStatusOptions = ref<IMOptionsType[]>([
  {
    value: "Infinity",
    label: getProxyT("dict6"),
  },
  {
    value: 0,
    label: getProxyT("dict7"),
  },
  {
    value: 1,
    label: getProxyT("dict8"),
  },
]);
export const searchList = ref<any>([
  {
    label: getProxyT("tripartite25"),
    type: "input",
    model: "name",
    allowClear: true,
    placeholder: getProxyT("tripartite34"),
  },
  {
    label: getProxyT("tripartite8"),
    type: "select",
    model: "support_pay",
    placeholder: getProxyT("tripartite13"),
    options: searchPayCapacityOptions,
    allowClear: true,
    searchClass: "search-item-width-200",
  },

  {
    label: getProxyT("tripartite7"),
    type: "select",
    model: "pay_type",
    placeholder: getProxyT("tripartite35"),
    options: searchPayTypeOptions,
    allowClear: true,
    searchClass: "search-item-width-200",
  },
  {
    label: getProxyT("tripartite11"),
    type: "select",
    model: "status",
    placeholder: getProxyT("tripartite14"),
    options: searchPayStatusOptions,
    allowClear: true,
    searchClass: "search-item-width-200",
  },
  {
    label: getProxyT("tripartite32"),
    type: "rangePicker",
    model: "create_time",
    placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
    showTime: { format: "HH:mm" },
    format: "YYYY-MM-DD HH:mm",
  },

  {
    label: getProxyT("tripartite33"),
    type: "rangePicker",
    model: "operate_time",
    placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
    showTime: { format: "HH:mm" },
    format: "YYYY-MM-DD HH:mm",
  },
]);
export const colorOptions = reactive<any>({
  0: "s-52c41a",
  1: "s-dc3545",
});
export const diabledMap = reactive<IMOptionsType[]>([
  {
    label: getProxyT("dict7"),
    value: 0,
  },
  {
    label: getProxyT("dict8"),
    value: 1,
  },
]);
export const operateType = ref<any>("");
export const drawerInstance = ref<any>(null);
export const drawerFormState = reactive<DrawerFormStateType<Array<string>, any>>({
  support_pay_passageways: [],
  payCapacity: [],
  id: undefined,
  code: undefined,
  secret_key: undefined,
  is_support_pay: undefined,
  pay_gateway_url: undefined,
  is_support_withdraw: undefined,
  support_withdraw_passageways: undefined,
  withdraw_gateway_url: undefined,
  sort: undefined,
  comment: undefined,
  pay_merchant_no: undefined,
  name: undefined,
  is_disabled: 0,
});
export const defaultFormState = deepClone(drawerFormState);
export const drawer_disable_ok_button = computed(() => {
  return (
    isEmptyType(drawerFormState.pay_merchant_no) ||
    isEmptyType(drawerFormState.name) ||
    isEmptyType(drawerFormState.payCapacity) ||
    isEmptyType(drawerFormState.sort) ||
    isEmptyType(drawerFormState.is_disabled)
  );
});
export const drawerInputValidators = reactive(createArray(false, 1));
export const userStateMap: IMOptionsType[] = [
  {
    value: 0,
    label: getProxyT("dict7"),
  },
  {
    value: 1,
    label: getProxyT("dict8"),
  },
];
